#ifndef _SERVER_H_
#define _SERVER_H_

#define forever	for(;;)

#define _WRITELOCK_ "fish.WRITELOCK"
#define _SERVER_ 1
#define _CLIENT_ !SERVER


/**
 ** Changes the password for the user (login) from oldpass to newpass
 **
 **	@param	oldpass		String containing the old password.
 **	@param	newpass		String containing the new password.
 **	@param	login		Integer containing the user ID;
 ** @return 			Returns status of error by CheckPass if oldpass is 
 **						wrong or status returned by ChangePass.
 **/
int passwd(char * oldpass, char * newpass, int login);

/**
 ** Creates a list of file's categories int the server.
 **
 **	@param	resp		Char array that contains the requested list.
 ** @return 			Returns amount of bytes in the category list.
 **/
int list_categories(char ** resp);

/**
 ** Creates a list of the users registered in the server.
 **
 **	@param	resp		Char array that contains the requested list.
 ** @return 			Returns amount of bytes in the users list.
 **/
int list_users(char ** resp);

/**
 ** Creates a list of files stored in the server for a given category.
 **
 **	@param	resp		Char array that contains the requested list.
 ** @param	category	Category name from to which the files belong.
 ** @return 			Returns amount of bytes in the category list.
 **/
int list_files(char ** resp, char * category);

/**
 ** Generates a new ticket for a given filname and user ID.
 **
 **	@param	filename	Name of the file for which to create the ticket.
 ** @param	tickp		Ticket parameters of the new ticket created by the 
 **						function.
 **	@param	login		Integer containing the user ID;
 ** @return 			Returns in < 0 if an error ocurred or 1 if OK.
 **/
int get_ticket(char * filename, ticketP * tickp, int login);

/**
 ** Cashes the ticket provided for a download.
 **
 **	@param	md5			Ticket ID to request exchange.
 ** @param	tickp		Ticket parameters of the new ticket created by the 
 **						function.
 **	@param	login		Integer containing the user ID;
 ** @return 			Returns in < 0 if an error ocurred or 1 if OK.
 **/
int use_ticket(ticketT md5, ticketP * tickp, int login);

/**
 ** Checks before uploading a file from client to server.
 **
 **	@param	filename	Physical name for the new file. 
 ** @param	size		Size of the file uploaded. 
 ** @return 			Returns in < 0 if an error ocurred or 1 if OK.
 **/
int upload(char * filename, int size);

#endif

